<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>新增地址</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/page.css">
    <script src="../js/jquery-3.2.1.min.js"></script>
    <script src="../js/media.js"></script>
    <script src="../js/common.js"></script>
    <style>

    </style>
</head>

<body>
    <!--头部-->
    <div class="public-header flex">
        <!--<span class="public-header-left-search"></span>-->
        <span class="public-header-left-back"></span>
        <span class="public-header-center">新增地址</span>
        <span class="public-header-right" @click='add_data()'>保存</span>
    </div>

    <!--正文-->
    <div class="Add-address bc-gray">
        <ul>
            <li>
                <span>联系人</span>
                <input type="text" placeholder="请输入名字" v-model="name">
                <img src="../img/通讯录@2x.png" alt="">
            </li>
            <li>
                <span>手机号码</span>
                <input type="text" placeholder="请输入11位手机号码" v-model="phone">
            </li>
            <li>
                <span>选择地区</span>
                <input type="text" placeholder="请输入地区信息" v-model="place">
                <img src="../img/定位@2x.png" alt="">
            </li>
            <li>
                <span>详细地址</span>
                <input type="text" placeholder="请输入街道门牌信息" v-model="address">
            </li>
            <li>
                <span>邮政编码</span>
                <input type="text" placeholder="请输入邮政编码" v-model="code">
            </li>
         
        </ul>
    </div>
    <script src='../js/vue.js'></script>
    <script src='../js/vue-resource.min.js'></script>

    <script>
        $(function () {
            $('.Add-address ul li').each(function () {
                $(this).find('input').blur(function () {
                    var text = $(this).attr('placeholder');
                    console.log($(this).val())
                    if ($(this).val() == '') {
                        alert(text)
                    }

                })
            })
        })
    </script>
    <script>
        $(function () {
            new Vue({
                el: 'body',
                data: {
                    name: '',
                    phone: '',
                    place: '',
                    address: '',
                    code: ''

                },
                ready: function () {

                },
                methods: {
                    add_data: function () {
                        this.$http.get(base_url + 'ZITAOHUI/user/addAddress', {
                            params: {
                                uid: 1,
                                name: this.name,
                                phone: this.phone,
                                detail: this.place + ',' + this.address,
                                postCode: this.code
                            }
                        }).then(function (data) {
                            console.log(data)
                            window.location.href = '../page/my-address.html'
                        })
                    }
                }

            })
        })
    </script>


 


</body>

</html>